//package com.demo.poi;
//
//import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
//import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//import org.apache.poi.ss.usermodel.*;
//import org.junit.Test;
//
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//
///**
// * @Author: yuxuepeng.com
// * @Description:
// * @Date: Created in 16:50 2022-5-16
// * @Modified By:获取公式并进行计算
// */
//
//public class DemoGongShiPOI01 {
//    @Test
//    public void ReadGongShi03() throws IOException {
//        String PATH = "D:\\xiangmu\\demo-poi\\";
//        FileInputStream fileInputStream = new FileInputStream(PATH + "\\测试个表格2003.xls");
//        Workbook workbook = new HSSFWorkbook(fileInputStream);
//        Sheet sheet1 = workbook.getSheet("Sheet1");
//        Row row = sheet1.getRow(4);
//        Cell cell = row.getCell(0);
//        //拿到计算公式
//        FormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator((HSSFWorkbook) workbook);
//
//        CellType cellType = cell.getCellType();
//        switch (cellType){
//            case FORMULA://公式
//                String formula = cell.getCellFormula();
//                System.out.println(formula);
//                //计算
//                CellValue evaluate = formulaEvaluator.evaluate(cell);
//                String cellValue = evaluate.formatAsString();
//                System.out.println(cellValue);
//                break;
//        }
//    }
//}
